package  
{
	import org.flixel.*;
	/**
	 * ...
	 * @author ...
	 */
	public class ExtrasState extends FlxState
	{
		private var _backBackground:FlxSprite;
		private var _mainMenuButton:FlxButtonPlus;
		private var _menuText1:FlxText;
		private var _menuText2:FlxText;
		
		private var _endingsHeader:FlxText;
		private var _badEndingButton:FlxButtonPlus;
		private var _goodEndingButton:FlxButtonPlus;
		private var _bestEndingButton:FlxButtonPlus;
		private var _toEndingNumber:uint;
		
		private var _creditsButton:FlxButtonPlus;
		
		private var _songsHeader:FlxText;
		private var _mainMenuMusicButton:FlxButtonPlus; //songNum 0
		private var _warehouseMusicButton:FlxButtonPlus; //songNum 1
		private var _cityMusicButton:FlxButtonPlus; //songNum 2
		private var _fairMusicButton:FlxButtonPlus; //songNum 3
		private var _creditsMusicButton:FlxButtonPlus; //songNum 4
		private var _songNumber:uint;
		private var _playNewSong:Boolean = false;
		private var _songTimerCounter:Number = 0.0;
		
		private var _soundEffectsHeader:FlxText;
		private var _batterySFXButton:FlxButtonPlus; //SoundNum 0
		private var _clockSFXButton:FlxButtonPlus; //SoundNum 1
		private var _jumpSFXButton:FlxButtonPlus; //SoundNum 2
		private var _light1SFXButton:FlxButtonPlus; //SoundNum 3
		private var _light2SFXButton:FlxButtonPlus; //SoundNum 4
		private var _light3SFXButton:FlxButtonPlus; //SoundNum 5
		private var _noPowerSFXButton:FlxButtonPlus; //SoundNum 6
		private var _soundNumber:uint;
		
		private var _artworkHeader:FlxText;
		private var _warehouseBackgroundButton:FlxButtonPlus; //ImgNum 0
		private var _cityBackgroundButton:FlxButtonPlus; //ImgNum 1
		private var _fairBackgroundButton:FlxButtonPlus; //ImgNum 2
		private var _omnistrainLogoButton:FlxButtonPlus; //ImgNum 3
		private var _artNumber:uint;
		
		private var _fadeInTimer:Number = 0.0;
		private var _fadeOutTimer:Number = 0.0;
		private const _fadeInMaxTime:Number = 1.0;
		private const _fadeOutMaxTime:Number = 1.0;
		private var _buttonPressed:Boolean = false;
		private var _fadeSprite:FlxSprite;
		
		private var _toWhere:uint;
		private const TOMAINMENU:uint = 0;
		private const TOENDINGS:uint = 1;
		private const TOCREDITS:uint = 2;
		
		public function ExtrasState(fromMainMenu:Boolean = false)
		{
			var background:FlxSprite = new FlxSprite(0, 0, ImageFiles.menuBackground);
			add(background);
			
			_backBackground = new FlxSprite(0, FlxG.height, ImageFiles.menuLeftButton);
			_backBackground.y -= _backBackground.height;
			add(_backBackground);
			
			var bgLight:FlxSprite = new FlxSprite(0, 0, ImageFiles.menuBackgroundLight);
			bgLight.blend = "multiply";
			add(bgLight);
			
			_mainMenuButton = new FlxButtonPlus(0, FlxG.height - 60, goToMainMenu);
			_menuText1 = new FlxText(0, 13, 200, "Back").setFormat("FightingSpirit", 30, 0x729954, "center");
			_menuText2 = new FlxText(_menuText1.x, _menuText1.y, _menuText1.width, _menuText1.text).setFormat("FightingSpirit", 36, 0xd8eba2, "center");
			var menuButtonSprite:FlxSprite = new FlxSprite().createGraphic(200, 60, 0x003a5c39);
			var menuButtonHighlightSprite:FlxSprite = new FlxSprite().createGraphic(200, 60, 0x00729954);
			_mainMenuButton.loadGraphic(menuButtonSprite, menuButtonHighlightSprite);
			_mainMenuButton.setMouseOverCallback(mouseOverSound);
			_mainMenuButton.loadText(_menuText1, _menuText2);
			add(_mainMenuButton);
			
			_endingsHeader = new FlxText(FlxG.width - 210, 20, 100, "Endings");
			_endingsHeader.setFormat("PowellAntique", 24, 0xFFFFFF, "center", 0xFF000000);
			add(_endingsHeader);
			
			_badEndingButton = new FlxButtonPlus(FlxG.width - 210, 60, goToEnding, [0]);
			var badEndingText1:FlxText = new FlxText(0, 0, 100, "Bad Ending").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var badEndingText2:FlxText = new FlxText(badEndingText1.x, badEndingText1.y, badEndingText1.width, badEndingText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_badEndingButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_badEndingButton.setMouseOverCallback(mouseOverSound);
			_badEndingButton.loadText(badEndingText1, badEndingText2);
			add(_badEndingButton);
			
			_goodEndingButton = new FlxButtonPlus(FlxG.width - 210, 90, goToEnding, [1]);
			var goodEndingText1:FlxText = new FlxText(0, 0, 100, "Good Ending").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var goodEndingText2:FlxText = new FlxText(goodEndingText1.x, goodEndingText1.y, goodEndingText1.width, goodEndingText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_goodEndingButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_goodEndingButton.setMouseOverCallback(mouseOverSound);
			_goodEndingButton.loadText(goodEndingText1, goodEndingText2);
			add(_goodEndingButton);
			
			_bestEndingButton = new FlxButtonPlus(FlxG.width - 210, 120, goToEnding, [2]);
			var bestEndingText1:FlxText = new FlxText(0, 0, 100, "Best Ending").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var bestEndingText2:FlxText = new FlxText(bestEndingText1.x, bestEndingText1.y, bestEndingText1.width, bestEndingText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_bestEndingButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_bestEndingButton.setMouseOverCallback(mouseOverSound);
			_bestEndingButton.loadText(bestEndingText1, bestEndingText2);
			add(_bestEndingButton);
			
			_creditsButton = new FlxButtonPlus(FlxG.width - 105, FlxG.height - 30, goToCredits);
			var creditsText1:FlxText = new FlxText(0, 0, 100, "Credits").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var creditsText2:FlxText = new FlxText(creditsText1.x, creditsText1.y, creditsText1.width, creditsText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_creditsButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_creditsButton.setMouseOverCallback(mouseOverSound);
			_creditsButton.loadText(creditsText1, creditsText2);
			add(_creditsButton);
			
			_songsHeader = new FlxText(FlxG.width - 315, 20, 100, "Music");
			_songsHeader.setFormat("PowellAntique", 24, 0xFFFFFF, "center", 0xFF000000);
			add(_songsHeader);
			
			_mainMenuMusicButton = new FlxButtonPlus(_songsHeader.x, _songsHeader.y + 40, playSong, [0]);
			var mainMenuMusicText1:FlxText = new FlxText(0, 0, 100, "Theme Music").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var mainMenuMusicText2:FlxText = new FlxText(mainMenuMusicText1.x, mainMenuMusicText1.y, mainMenuMusicText1.width, mainMenuMusicText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_mainMenuMusicButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_mainMenuMusicButton.setMouseOverCallback(mouseOverSound);
			_mainMenuMusicButton.loadText(mainMenuMusicText1, mainMenuMusicText2);
			add(_mainMenuMusicButton);
			
			_warehouseMusicButton = new FlxButtonPlus(_mainMenuMusicButton.x, _mainMenuMusicButton.y + 30, playSong, [1]);
			var warehouseMusicText1:FlxText = new FlxText(0, 0, 100, "Stage 1 Music").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var warehouseMusicText2:FlxText = new FlxText(warehouseMusicText1.x, warehouseMusicText1.y, warehouseMusicText1.width, warehouseMusicText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_warehouseMusicButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_warehouseMusicButton.setMouseOverCallback(mouseOverSound);
			_warehouseMusicButton.loadText(warehouseMusicText1, warehouseMusicText2);
			add(_warehouseMusicButton);
			
			_cityMusicButton = new FlxButtonPlus(_warehouseMusicButton.x, _warehouseMusicButton.y + 30, playSong, [2]);
			var cityMusicText1:FlxText = new FlxText(0, 0, 100, "Stage 2 Music").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var cityMusicText2:FlxText = new FlxText(cityMusicText1.x, cityMusicText1.y, cityMusicText1.width, cityMusicText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_cityMusicButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_cityMusicButton.setMouseOverCallback(mouseOverSound);
			_cityMusicButton.loadText(cityMusicText1, cityMusicText2);
			add(_cityMusicButton);
			
			_fairMusicButton = new FlxButtonPlus(_cityMusicButton.x, _cityMusicButton.y + 30, playSong, [3]);
			var fairMusicText1:FlxText = new FlxText(0, 0, 100, "Stage 3 Music").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var fairMusicText2:FlxText = new FlxText(fairMusicText1.x, fairMusicText1.y, fairMusicText1.width, fairMusicText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_fairMusicButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_fairMusicButton.setMouseOverCallback(mouseOverSound);
			_fairMusicButton.loadText(fairMusicText1, fairMusicText2);
			add(_fairMusicButton);
			
			_creditsMusicButton = new FlxButtonPlus(_fairMusicButton.x, _fairMusicButton.y + 30, playSong, [4]);
			var creditsMusicText1:FlxText = new FlxText(0, 0, 100, "Credits Music").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var creditsMusicText2:FlxText = new FlxText(creditsMusicText1.x, creditsMusicText1.y, creditsMusicText1.width, creditsMusicText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_creditsMusicButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_creditsMusicButton.setMouseOverCallback(mouseOverSound);
			_creditsMusicButton.loadText(creditsMusicText1, creditsMusicText2);
			add(_creditsMusicButton);
			
			_soundEffectsHeader = new FlxText(FlxG.width - 420, 20, 100, "SFX");
			_soundEffectsHeader.setFormat("PowellAntique", 24, 0xFFFFFF, "center", 0xFF000000);
			add(_soundEffectsHeader);
			
			_batterySFXButton = new FlxButtonPlus(_soundEffectsHeader.x, _soundEffectsHeader.y + 40, playSound, [0]);
			var batterySFXText1:FlxText = new FlxText(0, 0, 100, "Battery").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var batterySFXText2:FlxText = new FlxText(batterySFXText1.x, batterySFXText1.y, batterySFXText1.width, batterySFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_batterySFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_batterySFXButton.setMouseOverCallback(mouseOverSound);
			_batterySFXButton.loadText(batterySFXText1, batterySFXText2);
			add(_batterySFXButton);
			
			_clockSFXButton = new FlxButtonPlus(_batterySFXButton.x, _batterySFXButton.y + 30, playSound, [1]);
			var clockSFXText1:FlxText = new FlxText(0, 0, 100, "Clock").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var clockSFXText2:FlxText = new FlxText(clockSFXText1.x, clockSFXText1.y, clockSFXText1.width, clockSFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_clockSFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_clockSFXButton.setMouseOverCallback(mouseOverSound);
			_clockSFXButton.loadText(clockSFXText1, clockSFXText2);
			add(_clockSFXButton);
			
			_jumpSFXButton = new FlxButtonPlus(_clockSFXButton.x, _clockSFXButton.y + 30, playSound, [2]);
			var jumpSFXText1:FlxText = new FlxText(0, 0, 100, "Jump").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var jumpSFXText2:FlxText = new FlxText(jumpSFXText1.x, jumpSFXText1.y, jumpSFXText1.width, jumpSFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_jumpSFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_jumpSFXButton.setMouseOverCallback(mouseOverSound);
			_jumpSFXButton.loadText(jumpSFXText1, jumpSFXText2);
			add(_jumpSFXButton);
			
			_light1SFXButton = new FlxButtonPlus(_jumpSFXButton.x, _jumpSFXButton.y + 30, playSound, [3]);
			var light1SFXText1:FlxText = new FlxText(0, 0, 100, "Light 1").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var light1SFXText2:FlxText = new FlxText(light1SFXText1.x, light1SFXText1.y, light1SFXText1.width, light1SFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_light1SFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_light1SFXButton.setMouseOverCallback(mouseOverSound);
			_light1SFXButton.loadText(light1SFXText1, light1SFXText2);
			add(_light1SFXButton);
			
			_light2SFXButton = new FlxButtonPlus(_light1SFXButton.x, _light1SFXButton.y + 30, playSound, [4]);
			var light2SFXText1:FlxText = new FlxText(0, 0, 100, "Light 2").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var light2SFXText2:FlxText = new FlxText(light2SFXText1.x, light2SFXText1.y, light2SFXText1.width, light2SFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_light2SFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_light2SFXButton.setMouseOverCallback(mouseOverSound);
			_light2SFXButton.loadText(light2SFXText1, light2SFXText2);
			add(_light2SFXButton);
			
			_light3SFXButton = new FlxButtonPlus(_light2SFXButton.x, _light2SFXButton.y + 30, playSound, [5]);
			var light3SFXText1:FlxText = new FlxText(0, 0, 100, "Light 3").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var light3SFXText2:FlxText = new FlxText(light3SFXText1.x, light3SFXText1.y, light3SFXText1.width, light3SFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_light3SFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_light3SFXButton.setMouseOverCallback(mouseOverSound);
			_light3SFXButton.loadText(light3SFXText1, light3SFXText2);
			add(_light3SFXButton);
			
			_noPowerSFXButton = new FlxButtonPlus(_light3SFXButton.x, _light3SFXButton.y + 30, playSound, [6]);
			var noPowerSFXText1:FlxText = new FlxText(0, 0, 100, "No Power").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var noPowerSFXText2:FlxText = new FlxText(noPowerSFXText1.x, noPowerSFXText1.y, noPowerSFXText1.width, noPowerSFXText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_noPowerSFXButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_noPowerSFXButton.setMouseOverCallback(mouseOverSound);
			_noPowerSFXButton.loadText(noPowerSFXText1, noPowerSFXText2);
			add(_noPowerSFXButton);
			
			_artworkHeader = new FlxText(FlxG.width - 525, 20, 100, "Artwork");
			_artworkHeader.setFormat("PowellAntique", 24, 0xFFFFFF, "center", 0xFF000000);
			add(_artworkHeader);
			
			_warehouseBackgroundButton = new FlxButtonPlus(_artworkHeader.x, _artworkHeader.y + 40, showArtwork, [0]);
			var warehouseArtText1:FlxText = new FlxText(0, 0, 100, "Warehouse").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var warehouseArtText2:FlxText = new FlxText(warehouseArtText1.x, warehouseArtText1.y, warehouseArtText1.width, warehouseArtText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_warehouseBackgroundButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_warehouseBackgroundButton.setMouseOverCallback(mouseOverSound);
			_warehouseBackgroundButton.loadText(warehouseArtText1, warehouseArtText2);
			add(_warehouseBackgroundButton);
			
			_cityBackgroundButton = new FlxButtonPlus(_warehouseBackgroundButton.x, _warehouseBackgroundButton.y + 30, showArtwork, [1]);
			var cityArtText1:FlxText = new FlxText(0, 0, 100, "City").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var cityArtText2:FlxText = new FlxText(cityArtText1.x, cityArtText1.y, cityArtText1.width, cityArtText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_cityBackgroundButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_cityBackgroundButton.setMouseOverCallback(mouseOverSound);
			_cityBackgroundButton.loadText(cityArtText1, cityArtText2);
			add(_cityBackgroundButton);
			
			_fairBackgroundButton = new FlxButtonPlus(_cityBackgroundButton.x, _cityBackgroundButton.y + 30, showArtwork, [2]);
			var fairArtText1:FlxText = new FlxText(0, 0, 100, "Fair").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var fairArtText2:FlxText = new FlxText(fairArtText1.x, fairArtText1.y, fairArtText1.width, fairArtText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_fairBackgroundButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_fairBackgroundButton.setMouseOverCallback(mouseOverSound);
			_fairBackgroundButton.loadText(fairArtText1, fairArtText2);
			add(_fairBackgroundButton);
			
			_omnistrainLogoButton = new FlxButtonPlus(_fairBackgroundButton.x, _fairBackgroundButton.y + 30, showArtwork, [3]);
			var omniButtonText1:FlxText = new FlxText(0, 0, 100, "Omnistrain").setFormat("PowellAntique", 15, 0xDDDDDD, "center", 0xFF000000);
			var omniButtonText2:FlxText = new FlxText(omniButtonText1.x, omniButtonText1.y, omniButtonText1.width, omniButtonText1.text).setFormat("PowellAntique", 15, 0xFFFFFF, "center", 0xFF000000);
			_omnistrainLogoButton.loadGraphic(new FlxSprite().loadGraphic(ImageFiles.button), new FlxSprite().loadGraphic(ImageFiles.buttonHighlight));
			_omnistrainLogoButton.setMouseOverCallback(mouseOverSound);
			_omnistrainLogoButton.loadText(omniButtonText1, omniButtonText2);
			add(_omnistrainLogoButton);
			
			_fadeSprite = new FlxSprite().createGraphic(640, 480, 0xff000000);
			_fadeSprite.alpha = 1;
			add(_fadeSprite);
			
			if (!fromMainMenu)
			{
				FlxG.playMusic(SoundFiles.themeMusic);
			}
		}
		
		override public function update():void 
		{
			if (_fadeInTimer < _fadeInMaxTime && !_buttonPressed)
			{
				_fadeInTimer += FlxG.elapsed;
				
				_fadeSprite.alpha = Math.abs(1 - (_fadeInTimer / _fadeInMaxTime));
			}
			
			if (_buttonPressed)
			{
				fadeOut();
			}
			
			if (_playNewSong)
			{
				playNewSong();
			}
			
			super.update();
		}
		
		private function fadeOut():void
		{
			_fadeOutTimer = _fadeSprite.alpha / _fadeOutMaxTime;
			_fadeOutTimer += FlxG.elapsed;
			
			if (_fadeOutTimer >= _fadeOutMaxTime)
			{
				switch (_toWhere)
				{
				case TOMAINMENU:
					FlxG.state = new MainMenuState(false, false);
					break;
				case TOENDINGS:
					FlxG.state = new ExtrasEndingState(_toEndingNumber);
					break;
				case TOCREDITS:
					FlxG.state = new CreditsState(true, true);
					break;
				}
			}
			
			if ( _fadeSprite.alpha < _fadeOutTimer / _fadeOutMaxTime)
			{
				_fadeSprite.alpha = _fadeOutTimer / _fadeOutMaxTime;
			}
		}
		
		public function goToMainMenu():void
		{
			if (!_buttonPressed && _fadeSprite.alpha < .80)
			{
				FlxG.play(SoundFiles.selectSound);
				_buttonPressed = true;
				_toWhere = TOMAINMENU;
			}
		}
		
		private function goToEnding(ending:uint):void
		{
			if (!_buttonPressed && _fadeSprite.alpha < .80)
			{
				FlxG.play(SoundFiles.selectSound);
				_buttonPressed = true;
				_toWhere = TOENDINGS;
				_toEndingNumber = ending;
			}
		}
		
		private function goToCredits():void
		{
			if (!_buttonPressed && _fadeSprite.alpha < .80)
			{
				FlxG.play(SoundFiles.selectSound);
				FlxG.music.fadeOut(1.0);
				_buttonPressed = true;
				_toWhere = TOCREDITS;
			}
		}
		
		private function playSong(songNumber:uint):void
		{
			if (!_playNewSong && _fadeSprite.alpha < .80)
			{
				FlxG.music.fadeOut(1.0);
				_songNumber = songNumber;
				_playNewSong = true;
			}
		}
		
		private function playNewSong():void
		{
			_songTimerCounter += FlxG.elapsed;
			
			if (_songTimerCounter >= 1.0)
			{
				_playNewSong = false;
				_songTimerCounter = 0.0;
				
				switch (_songNumber)
				{
				case 0:
					FlxG.playMusic(SoundFiles.themeMusic);
					break;
				case 1:
					FlxG.playMusic(SoundFiles.warehouseMusic);
					break;
				case 2:
					FlxG.playMusic(SoundFiles.cityMusic);
					break;
				case 3:
					FlxG.playMusic(SoundFiles.fairMusic);
					break;
				case 4:
					FlxG.playMusic(SoundFiles.creditsMusic);
					break;
				}
			}
		}
		
		private function playSound(soundNumber:uint):void
		{
			switch (soundNumber)
			{
			case 0:
				FlxG.play(SoundFiles.batterySound);
				break;
			case 1:
				FlxG.play(SoundFiles.clockSound);
				break;
			case 2:
				FlxG.play(SoundFiles.jumpSound);
				break;
			case 3:
				FlxG.play(SoundFiles.lightLevel1Sound);
				break;
			case 4:
				FlxG.play(SoundFiles.lightLevel2Sound);
				break;
			case 5:
				FlxG.play(SoundFiles.lightLevel3Sound);
				break;
			case 6:
				FlxG.play(SoundFiles.noPowerSound);
				break;
			}
		}
		
		private function showArtwork(artNumber:uint):void
		{
			_artNumber = artNumber;
			FlxG.fade.start(0xFF000000, 1, goToArt);
		}
		
		private function goToArt():void
		{
			FlxG.state = new ExtrasArtworkState(_artNumber);
		}
		
		private function mouseOverSound():void
		{
			FlxG.play(SoundFiles.mouseOverSound, 0.75);
		}
	}

}